//好友对战 store
import Vue from 'vue'
import Vuex from 'vuex'
import { getStorage,setStorage} from '@/utils/index.js'
Vue.use(Vuex)
const store = {
  namespaced: true,
  state: {
    roomId:0,
    roomStatus:0,//0有效 1失效
  },
  mutations: {
    setRoomId(state,{roomId,from="own"}){//换成对象形式
      state.roomId = roomId;
      if(from=='own'){
        setStorage("roomId",roomId);
        console.log('setLocaLStorage')
      }
    },
    setRoomStatus(state,status){
      state.roomStatus = status;
    }
  }
}
//获取本地缓存
getStorage(store.state,"roomId",0);
export default store
